<div class="tpl-content-wrapper">
    <div class="row-content am-cf">
        <div class="row">
            <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                <div class="widget am-cf">
                    <div class="widget-head am-cf">
                        <div class="widget-title  am-cf">{$title}</div>
                    </div>
                    <form id="m_form" action="{:U('detail')}">
                    <div class="widget-body  am-fr">
                        <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                            <div class="am-form-group">

                            </div>
                        </div>
                        <div class="am-u-sm-12">
                            <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " >
                                <thead>
                                    <tr>
                                        <th>名字</th>
                                        <th>手机</th>
                                        <th>邮箱</th>
                                        <th style="text-align: center">内容</th>
                                        <th>留言日期</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody id="c_list">
                                    <volist name="data" id="vo">
                                        <php>
                                            $more_img = explode(',',$vo['more_img'],2);
                                        </php>
                                        <tr class="gradeC">
                                            <td>{$vo.username}</td>
                                            <td>{$vo.mobile}</td>
                                            <td>{$vo.email}</td>
                                            <td style="min-width: 454px">{$vo.msg}</td>

                                            <td>{$vo.c_time|date='Y年m月d日 H:i:s',###}</td>
                                            <td>
                                                <div class="tpl-table-black-operation">
                                                    <a data_id="{$vo.id}" href="javascript:void(0);" class="look tpl-table-black-operation-del">
                                                        <i class="am-icon-desktop"></i> 查看
                                                    </a>
                                                </div>
                                            </td>
                                        </tr>
                                    </volist>
                                </tbody>
                            </table>
                        </div>
                        <div class="am-u-lg-12 am-cf" >
                            <div class="am-fr" id="page">
                                {$page}
                            </div>
                        </div>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<!--页码-->
<script src="__PUBLIC__js/common.js"></script>
<script src="__LAYER__/layer.js"></script>
<script>
    $(document).ready(function(){
        $("#del_check_all").click(function(){
            $(".del_check").prop('checked',$(this).prop('checked'));
        });

        $(".del_check").click(function(){
            if(!$(this).prop("checked")){
                $("#del_check_all").prop("checked",false);
            }else{
                if($(".del_check:checked").length == $(".del_check").length){
                    $("#del_check_all").prop("checked",true);
                }
            }
        })

        $("#m_form").on("click",".look",function () {
//            var name = "李红";
//            var mobile = "电话:李红";
//            var email = "邮箱:李红";
//            var msg = "内容:李红";
//            layer.open({
//                title: '留言详情'
//                ,content: '<p>'+name+'</p><p>可以填写任意的layer代码</p>'
//            });

            var url   = $("#m_form").attr("action");
            var id = $(this).attr("data_id");
            $.get(
                url,
                {id:id},
                function(data){
                    console.log(data);
                    var content = "";
                    content += '<table>';

                    content += '<tr>';
                    content += '<td style="min-width: 50px">姓名：</td>';
                    content += '<td>' + data.username + '</td>';
                    content += '</tr>';

                    content += '<tr>';
                    content += '<td>手机：</td>';
                    content += '<td>' + data.mobile + '</td>';
                    content += '</tr>';

                    content += '<tr>';
                    content += '<td>邮箱：</td>';
                    content += '<td>' + data.email + '</td>';
                    content += '</tr>';

                    content += '<tr>';
                    content += '<td valign="top">内容：</td>';
                    content += '<td>' + data.msg + '</td>';
                    content += '</tr>';
                    content += '</table>';
                    layer.open({
                        title: '留言详情'
                        ,content:content
                    });
                 },
                    "json"
             )
        })

        $("#page").on("click","a",function(event){
//            alert("a");
            var url = $(this).attr("href");
            $.ajax({
                url: url,
                type: 'GET',
                dataType: 'json',
            })
            .done(function(res) {
                // 在js里面使用PHP语法
                // 什么时候可以用
                // 你就想要PHP输出字符串的时候 不涉及到 js变量
                // 什么时候不可以用
                // 当你想要传输js 变量给PHP处理的时候
                var sList = '';
                var look_url = "{:U('News/delete?id=dddd')}";
                var look = "";


                $.each(res.data,function(k,v){
                    look = look_url.replace('eeee',v.id);
                    sList += '<tr class="gradeC">';
                    sList += '<td>' + v.username + '</td>';
                    sList += '<td>' + v.mobile +'</td>';
                    sList += '<td>' + v.email +'</td>';
                    sList += '<td style="min-width: 454px">' + v.msg +'</td>';
                    sList += '<td>' + get_date(v.c_time) +'</td>';
                    sList += '<td>';
                    sList += '<div class="tpl-table-black-operation">';
                    sList += '<a data_id='+v.id+' href="javascript:void(0);"' + ' class="look tpl-table-black-operation-del' + '"> ';
                    sList += '<i class="am-icon-desktop"></i> 查看';
                    sList += '</a>';
                    sList += '</div>';
                    sList += '</td>';
                    sList += '</tr>';
                });
                $('#c_list').html(sList);
                $('#page').html(res.page);
            });
            event.preventDefault();//组织跳转
        });

    });//ready结束
</script>